<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>prototype的作用</title>
</head>
<body>
    <script>
        function Person()
        {}

        Person.prototype.running = function()
        {
            console.log("跑步");
        }

        Person.prototype.eating = function()
        {
            console.log("吃饭");
        }

        function Student(name,age,height)
        {
            this.name = name;
            this.age = age;
            this.height = height;
        }

        function Teacher(name,age,height)
        {
            this.name = name;
            this.age = age;
            this.height = height;
        }
        Student.prototype = Person.prototype;
        Teacher.prototype = Person.prototype;
        
        var p1 = new Student("cq",18,1.88);
        var p2 = new Teacher("cq",30,1.90);

        p1.running();
        p2.running();

    </script>
</body>
</html>